package com.vvlive.caibao.smartcity.ui;

import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;

import com.vvlive.caibao.smartcity.base.BaseActivity;
import com.vvlive.caibao.smartcity.bean.Person;
import com.vvlive.caibao.smartcity.utils.ImageUtil;
import com.vvlive.caibao.smartcity.view.CommonActionBar;

import org.kymjs.kjframe.ui.BindView;

import io.rong.imkit.RongIM;
import smartcity.vvlive.caibao.com.smartc.R;

/**
 * Created by zhj on 2015/6/29.
 */
public class PersonDetailsActivity extends BaseActivity {

    @BindView(id = R.id.pd_name)
    private TextView mName;
    @BindView(id = R.id.pd_number)
    private TextView mNumber;

    @BindView(id = R.id.pd_department)
    private TextView mDepartment;
    @BindView(id = R.id.pd_job)
    private TextView mJob;
    @BindView(id = R.id.pd_mobile)
    private TextView mMobile;

    @BindView(id = R.id.pd_avatar)
    private ImageView mAvatar;
    @BindView(id = R.id.pd_call, click = true)
    private Button mCall;
    @BindView(id = R.id.pd_text, click = true)
    private Button mText;

    private Person person;

    @Override
    protected int getContentViewRes() {
        return R.layout.activity_person_details;
    }

    @Override
    public void initWidget() {
        super.initWidget();
        CommonActionBar actionBar = super.getCommonActionBar();
        actionBar.setMoreVisible(false);
        actionBar.setTitle("人员详情");

        person = (Person) getIntent().getSerializableExtra("person");
        ImageUtil.loadImage(this, person.getPortrait(), mAvatar, 0);
        mName.setText(person.getName());
        mNumber.setText("工号：" + person.getNumber());
        mDepartment.setText(person.getDepartment());
        mJob.setText(person.getJob());
        mMobile.setText(person.getMobile());
    }

    @Override
    public void widgetClick(View v) {
        super.widgetClick(v);
        switch (v.getId()){
            case R.id.pd_call:
                toast("打电话");
                break;

            case R.id.pd_text:
               // toast("发消息");
                RongIM.getInstance().startPrivateChat(this, person.getNumber(), person.getName());
                break;
        }
    }

}
